*** REPLICATION TOOLKIT ***

* AUTHORS: CIMINELLI DUVAL FURCERI 

* ARTICLE: EMPLOYMENT PROTECTION DEREGULATION AND LABOR SHARES IN ADVANCED ECONOMIES 

* JOURNAL: REVIEW OF ECONOMICS AND STATISTICS

* OUTPUT: FIGURE E8 (ONLINE APPENDIX)

***************************

cd ""

use "DTA files/Dataset", clear

**************** PLOT LABOR SHARES BY INDUSTRY *******************

gen a = 100*lab/va

* Create variable with industry names (short version)
gen ind_desc_short = ind_desc

replace ind_desc_short="Food, Beverages & Tobacco" if id_industry==1
replace ind_desc_short="Textiles" if id_industry==2
replace ind_desc_short="Wood, Paper, Reproduction" if id_industry==3
replace ind_desc_short="Coke & Petroleum" if id_industry==4
replace ind_desc_short="Chemicals" if id_industry==5
replace ind_desc_short="Rubber & Plastics" if id_industry==6
replace ind_desc_short="Basic Metals" if id_industry==7
replace ind_desc_short="Electrical & Optical" if id_industry==8
replace ind_desc_short="Machinery & Equipment" if id_industry==9
replace ind_desc_short="Transport Equipment" if id_industry==10
replace ind_desc_short="Others Manufacturing" if id_industry==11
replace ind_desc_short="Wholesale & Retail, Motor" if id_industry==12
replace ind_desc_short="Wholesale, ex-Motor" if id_industry==13
replace ind_desc_short="Retail, ex-Motor" if id_industry==14
replace ind_desc_short="Transport & Storage" if id_industry==15
replace ind_desc_short="Postal & Courier" if id_industry==16
replace ind_desc_short="Publishing & Audiovisual" if id_industry==17
replace ind_desc_short="Telecommunications" if id_industry==18
replace ind_desc_short="IT & Others" if id_industry==19
replace ind_desc_short="Agriculture" if id_industry==20
replace ind_desc_short="Mining & Quarrying" if id_industry==21
replace ind_desc_short="Utilities" if id_industry==22
replace ind_desc_short="Construction" if id_industry==23
replace ind_desc_short="Accomodation & Food Services" if id_industry==24
replace ind_desc_short="Financial & Insurance" if id_industry==25
replace ind_desc_short="Real Estate" if id_industry==26
replace ind_desc_short="Professional Activities" if id_industry==27
replace ind_desc_short="PA, Defense & SS" if id_industry==28
replace ind_desc_short="Education" if id_industry==29
replace ind_desc_short="Health & Social Activities" if id_industry==30
replace ind_desc_short="Arts & Recreation" if id_industry==31
replace ind_desc_short="Other Service Activities" if id_industry==32

* Graph labor share by industry over time
preserve 
collapse (median) median=a (p25) p25=a (p75) p75=a if $sample0, by(id_industry year) 

egen id = group(id_industry)
sum id
local max = r(max)

* Create matrix having industries as row names (by alphabetic order)
mat j=J(`max',1,0)
mat rownames j = Food&Beverages&Tobacco Textiles Wood&Paper&Reproduction Coke&Petroleum Chemicals Rubber&Plastics BasicMetals Electrical&Optical Machinery&Equipment TransportEquipment OthersManufacturing  Wholesale&RetailMotor WholesaleEx-Motor RetailEx-Motor Transport&Storage Postal&Courier Publishing&Audiovisual Telecommunications IT&Others Agriculture Mining&Quarrying  Utilities Construction Accomodation&FoodServices Financial&Insurance RealEstate Professional&SupportActivities PA&Defense&SS Education Health&Social Arts&Recreation OtherServiceActivities

mat li j
local nospace: subinstr loc nodot " " "", all
local respace: subinstr loc nospace "'`" "' `", all
mat rownames j = `respace'

* Graph
forvalues i=1/`max' {

* Create local macro with name of the industry 
local names : rownames j
local this_name = "`:word `i' of `names''"

* Create graph
graph twoway line median p25 p75 year if id==`i', title("`this_name'") ////
lpattern(solid dash dash) lwidth (medium thin thin) xtitle("") yla(40(60)100)  xla(1970(10)2015)  ///
legend(label(1 "Median")label(2 "25{superscript:th} pct.")label(3 "75{superscript:th} pct.") size(small)) legend(rows(1)) graphregion(color(white))
graph copy a_industry_`i', replace
}
restore

* Combine graphs in a single graph
grc1leg a_industry_1 a_industry_2 a_industry_3 a_industry_4 a_industry_5 a_industry_6 a_industry_7 a_industry_8 a_industry_9 a_industry_10 a_industry_11 ////
a_industry_12 a_industry_13 a_industry_14 a_industry_15 a_industry_16 a_industry_17 a_industry_18 a_industry_19 a_industry_20 a_industry_21 a_industry_22 a_industry_23 ///
a_industry_24 a_industry_25 a_industry_26 a_industry_27 a_industry_28 a_industry_29 a_industry_30 a_industry_31 a_industry_32, cols(4) legendfrom(a_industry_1) graphregion(color(white))
graph export "Figures/E8.png", replace
